package edu.tapestry.iddb.client.components;

import iddb.PluginIdentificator;

import java.util.List;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

import edu.tapestry.iddb.client.helpers.DataStorage;
import edu.tapestry.iddb.client.helpers.PI;
import edu.tapestry.iddb.client.pages.buddyIM.ListBuddyIM;

public class Layout {

	@ApplicationState
	private DataStorage storage;

	@Property
	private PI currentPlugin;

	@InjectPage
	private ListBuddyIM listBuddiesPage;

	@Inject
	private BeanModelSource beanModelSource;

	@Inject
	private ComponentResources resources;

	private BeanModel<PI> model;

	void pageLoaded() {
		this.model = beanModelSource.create(PI.class, true, resources
				.getMessages());
		this.model.add("details", null);

	}

	public List<PI> getConnectedPlugins() {
		return storage.getConnectedPluginsIdents();
	}

	public Object onActionFromBuddiesLink(PI ident) {
		return listBuddiesPage.initialize(ident);
	}

}
